#pragma once

class CPoint3D
{
public:
	CPoint3D();
	CPoint3D(double x, double y, double z);
	~CPoint3D();
	double x, y, z;
public:
	CPoint3D operator-(const CPoint3D& v) const {
		return { x - v.x, y - v.y, z - v.z };
	}

	CPoint3D operator+(const CPoint3D& v) const {
		return { x + v.x, y + v.y, z + v.z };
	}

	CPoint3D operator*(double scalar) const {
		return { x * scalar, y * scalar, z * scalar };
	}

	double Dot(const CPoint3D& v) const {
		return x * v.x + y * v.y + z * v.z;
	}

	CPoint3D Cross(const CPoint3D& v) const {
		return { y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x };
	}

	double Length() const {
		return sqrt(x * x + y * y + z * z);
	}

	CPoint3D Normalize() const {
		double len = Length();
		return { x / len, y / len, z / len };
	}
};

CPoint3D::CPoint3D(double x, double y, double z):x(x),y(y),z(z)
{
}

CPoint3D::~CPoint3D()
{
}